package com.bloveoacom.weichi.adapter;

import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.text.SpannableStringBuilder;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.blankj.utilcode.util.SpanUtils;
import com.bloveoacom.util.GlideUtil;
import com.bloveoacom.util.MyClickableSpan;
import com.bloveoacom.util.StringUtils;
import com.bloveoacom.weichi.R;
import com.bloveoacom.weichi.bean.CommentBean;
import com.bloveoacom.weichi.bean.CommentHelperModel;
import com.bloveoacom.weichi.bean.PostDetailBean;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.ArrayList;
import java.util.List;

/**
 * author: yjl
 * e-mail: 1271901673@qq.com
 * time  : 2018/9/20
 * desc  :
 */
public class MyComment2Adapter extends BaseQuickAdapter<CommentBean.CommentSon,BaseViewHolder>{
    public MyComment2Adapter(int layoutResId, @Nullable List<CommentBean.CommentSon> data) {
        super(layoutResId, data);
    }

    CommentBean commentBean;


    public void setCommentBean(CommentBean commentBean){
        this.commentBean = commentBean;
    }

    @Override
    protected void convert(BaseViewHolder helper, CommentBean.CommentSon item) {
        GlideUtil.loadCircleImage((ImageView) helper.getView(R.id.iv_head), StringUtils.getFullUrl(item.headImg, 0));
        helper.setText(R.id.tv_username, item.userName);
        helper.setText(R.id.tv_time, "123454");

        helper.setVisible(R.id.ll_comment,false);
        boolean noHasReply = true;
        if(commentBean!=null){
            noHasReply = String.valueOf(item.replyUserId).equals(String.valueOf(commentBean.getUserId()))|| String.valueOf(item.replyUserId).equals(String.valueOf(item.userId));
        }
        if(noHasReply){
            helper.setText(R.id.tv_content, item.comment);
        }else{
            helper.setText(R.id.tv_content, "回复"+item.replyUserName+":"+item.comment);
        }
        helper.addOnClickListener(R.id.tv_content);
    }

}
